home *** CD-ROM | disk | FTP | other *** search
/ Amoszine 8 / Amoszine 8 (Disk 2 of 3).adf / Powerbobs.lha / powerbobsv1.0 / demos / Stars.asc < prev   
Text File  |  1995-06-30  |  4KB  |  121 lines

  1. '-- Program: Stars 
  2. '-- Author: Paul Overy 
  3. '
  4. '-- This program uses large values, which are scaled down to fit   
  5. '-- the screen replacing the need to carry out floating point calculations.    
  6. '
  7. '-- Unlike the Popcorn, this demo does not make full use of all the  
  8. '-- Powerbob commands (ie. Plsr), it can still be sped up.       
  9. '  
  10. 'Bank 14 - Hold large logo.
  11. 'Bank 15 - Holds gfx balls.  
  12. '
  13. Hide 
  14. '
  15. '-- Number of stars/balls
  16. Repeat : Input "Number of balls max(64) ";N : Until N>0 and N<65
  17. '
  18. Dim SPEED(N),G(N),R(N),T(N),MX(N),MY(N)
  19. Dim TEMP_MX(N),TEMP_MY(N)
  20. Dim X(N),Y(N),C(N),OX(N),OY(N),S_RAN(64),TIME(64)
  21. '
  22. '--------------------------------------- 
  23. Load "PowerBobsV1.0:DEMOS/Bob_Stars.Abk"
  24. '--------------------------------------- 
  25. '
  26. '-- This will cause the main program to intialise itself.    
  27. For K=0 To N : C(K)=1 : Next K
  28. '
  29. Proc _GET_BOBS[N]
  30. '
  31. Break Off 
  32. NUL=Execall(-132) : Rem Turn off multitasking
  33. '
  34. Repeat 
  35.    '
  36.    '-- Star reset position counter.   
  37.    Pdec Varptr(C(0)),0 To N
  38.    '
  39.    '-- Star size toggle counter.
  40.    Pdec Varptr(T(0)),0 To N
  41.    '
  42.    ' -- Calculate all new X-axis star positions.  
  43.    Psum Varptr(X(0)),Varptr(MX(0)),0 To N
  44.    '
  45.    ' -- Calculate all new y-axis star positions.  
  46.    Psum Varptr(Y(0)),Varptr(MY(0)),0 To N
  47.    '
  48.    For K=0 To N
  49.       '
  50.       '-- Reset star to centre 
  51.       If C(K)=0
  52.          MX(K)=Rnd(2048)-1024 : Rem     new angle  
  53.          MY(K)=Rnd(2048)-1024 : Rem     "   "  
  54.          X(K)=81920+MX(K)*16 : Rem      new X-axis starting point   
  55.          Y(K)=65535+MY(K)*16 : Rem       "  Y  "      "       " 
  56.          SPEED(K)=Rnd(1024)+1 : Rem     New Speed.   
  57.          C(K)=Rnd(20)+25 : Rem          Time star stay on screen.     
  58.          R(K)=C(K)/16 : Rem             store fade in reset value.     
  59.          T(K)=R(K) : Rem                Reset fade in counter.    
  60.          G(K)=16 : Rem                  Start with a small star.  
  61.       End If 
  62.       '
  63.       TEMP_MX(K)=MX(K)/SPEED(K) : TEMP_MY(K)=MY(K)/SPEED(K)
  64.       '
  65.       '-- Increase the size of a star.   
  66.       If T(K)=-1 Then Dec G(K) : T(K)=R(K)
  67.       '
  68.       '-- Use large numbers & divide them down instead of using floats.
  69.       OX(K)=X(K)/512 : OY(K)=Y(K)/512
  70.       '
  71.    Next K
  72.    '
  73.    '-- Speed up stars.  
  74.    Psum Varptr(MX(0)),Varptr(TEMP_MX(0)),1 To N
  75.    Psum Varptr(MY(0)),Varptr(TEMP_MY(0)),1 To N
  76.    '
  77.    ' -- Place all bobs.   
  78.    Pbob Varptr(OX(0)),Varptr(OY(0)),Varptr(G(0)),1 To N
  79.    '
  80.    ' -- Draw all bobs, and show physical screen.    
  81.    Pbob Update : Screen Swap 
  82.    '
  83.    '--  Faster machines need to wait for a complete screen refresh. 
  84.    '--  Otherwise there would be no point using a buffered screen.
  85.    Wait Vbl 
  86.    '
  87. Until Not Btst(6,$BFE001) : Rem -- Test left mouse 
  88. '
  89. NUL=Execall(-138) : Rem Turn on Multitasking 
  90. Break On 
  91. '  
  92. Procedure _GET_BOBS[_BOBS]
  93.    '
  94.    Unpack 15 To 0 : Rem -- Get graphics from bank  
  95.    '
  96.    N=1 : Rem -- Bob image counter 
  97.    For X=0 To 304 Step 16
  98.       Get Bob N,X,Y+64 To X+16,Y+79 : Inc N
  99.    Next X
  100.    '
  101.    '-- Set up screen buffering to stop flicker  
  102.    '
  103.    Cls 0
  104.    Unpack 14 To 0 : Rem      -- Get logo screen  
  105.    Double Buffer : Rem       -- Screen buffering to stop flicker    
  106.    Autoback 0 : Rem          -- Turn off Amos automatic screen buffer system 
  107.    Bob Update Off : Rem      -- (not really needed)    
  108.    Sprite Update Off : Rem   -- (not really needed)     
  109.    Make Mask : Rem           -- Must do this, or no masks will be created.  
  110.    '                         -- Unlike Amos bobs, for speed this is not 
  111.    '                         -- automatic when bobs are first drawn.
  112.    '
  113.    Reserve Pbobs _BOBS : Rem -- The total amount of bobs being used 
  114.    Pbob Dbuf True : Rem      -- Double buffering to be used on Pbobs   
  115.    '
  116.    For K=1 To _BOBS
  117.       Pbob Height K,15
  118.    Next K
  119.    '
  120. End Proc
  121.